<?php
// include function files for this application
require_once('/home/domains/uny-con.com/public_html/uny-con_fns.php');
if (!session_id()) { session_start(); }

//get some variables
if (isset($_POST['room_name'])) $room_name = trim($_POST['room_name']);
if (isset($_GET['room'])) $delete_room = urldecode($_GET['room']);

if (!check_valid_user() || ($_SESSION['admin'] != 't')) {
	do_html_header('Unauthorized access', staysmall, $uny);
	echo 'You are not logged in or are not authorized to view this page. Please move along.';
	print_brs(6);
	do_html_footer(news);
	exit;
	}


if (isset($delete_room)) {
	$conn = db_connect();
	$result = pg_query("DELETE FROM rooms WHERE room_name = '$delete_room'");
	header("Location: ".$conf['base_path']."registration/manage_rooms.php");
	exit;
	}

do_html_header('Room Management', staysmall, $uny);

if (isset($room_name)) {
	$conn = db_connect();
	$result = pg_query("INSERT INTO rooms (room_name) VALUES ('$room_name')");
	}


?>
<br /><form method=post action="<? echo $_SERVER['PHP_SELF'] ?>">
Room Name: <input type="text" name="room_name" size="30" maxlength="45">
     <input type="submit" name="Add Room" value="Add Room">
</form>

<?
echo "<h2>Current Rooms entered</h2>";
$room_array = get_rooms();
if (!empty($room_array)) {
	echo "<ul>\n";
	foreach ($room_array as $thisroom) {
		echo "<li class=\"infolist\">".$thisroom['room_name']." <a href=\"manage_rooms.php?room=".urlencode($thisroom['room_name'])."\">[delete]</a></li>\n";
		}
	echo "</ul>\n";
	}
	
do_html_footer(news);
?>